package com.shihb.creationalpatterns;

import java.util.Calendar;

/**
 *Description:抽象工厂模式 负责创建其他工厂
 *Version:1.0.0
 *@author shihb
 *@date 2020/4/20 16:20
 */
public class  AbstractFactoryPattern {

  public static void main(String[] args) {

    Calendar.getInstance();
    Factory xiaomi=new XiaoMiFactory();
    Factory huawe= new HuaWeiFactory();
    Phone xiaomiPhone=xiaomi.makePhone();
    Phone huaweiPhone=huawe.makePhone();
    xiaomiPhone.call();
    huaweiPhone.call();
    Route xiaomiRoute=xiaomi.makeRoute();
    Route huaweiRoute=huawe.makeRoute();
    xiaomiRoute.wifi();
    huaweiRoute.wifi();

  }
}

interface Phone{
  void call();
}
interface Route{
  void wifi();
}
class XiaoMiPhone implements  Phone{
  @Override
  public void call() {
    System.out.println("小米打电话");
  }
}
class HuaWeiPhone implements  Phone{
  @Override
  public void call() {
    System.out.println("华为打电话");
  }
}
class XiaoMiRouter implements Route{

  @Override
  public void wifi() {
    System.out.println("小米wifi");
  }
}
class HuaWeiRouter implements Route{

  @Override
  public void wifi() {
    System.out.println("华为wifi");
  }
}
interface Factory {
  Phone makePhone();
  Route makeRoute();
}
class XiaoMiFactory implements Factory {

  @Override
  public Phone makePhone() {
    return new XiaoMiPhone();
  }

  @Override
  public Route makeRoute() {
    return new XiaoMiRouter();
  }
}
class HuaWeiFactory implements Factory {

  @Override
  public Phone makePhone() {
    return new HuaWeiPhone();
  }

  @Override
  public Route makeRoute() {
    return new HuaWeiRouter();
  }
}
